<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <title>daiban</title>
    <style>
        * {
            margin: 0;
            padding: 0;
            list-style: none;
            text-decoration: none;
            box-sizing: border-box;
        }
        
        .boox {
            width: 300px;
            height: 400px;
            background: #f7f7f7;
            margin: auto;
            text-align: center;
        } 
        .boox h3{
            font-weight: 500;
            color: black;
        }
        .boox .add,.boox .list li{
            background: #efeaea;
            line-height: 33px;
            width: 100%;
            font-size: 15px;
            padding: 0 10px;
            height: 30px;
            cursor: pointer;
            position: relative;
            text-align: left;
        }
        .boox .list li{
            border-top: 1px solid #f78a8a;
        }
        
        .boox .list li>div {
            position: absolute;
            top: 0;
            right: 0;
        }
        
        .boox .list li>div button {
            display: block;
            outline: none;
            border: 1px solid #f78a8a;
            padding: 3px 5px;
            border-radius: 5px;
        }
        
        .boox .list li:hover div {
            display: block;
        }
        
        .boox .list li>div {
            display: none;
        }
        
        .on {
            background: white;
        }
        
        .tw {
            background: white;
        }
        
        .th {
            background: white;
        }
        
        .main {
            display: none;
        }
        
        .main .warp {
            height: 100vh;
            background: rgba(0, 0, 0, 0.17);
            position: fixed;
            top: 0;
            width: 100%;
            display: flex;
            justify-content: center;
            align-items: center;
        }
        
         .main .input {
            height: 264px;
            padding: 40px;
            background: white;
            width: 500px;
            position: relative;
        }
        
        .warp .off {
            position: absolute;
            font-size: 20px;
            top: 20px;
            right: 20px;
        }
        
        .main .input input {
            width: 100%;
            border-radius: 5px;
            padding: 5px 15px;
            outline: none;
            border: 1px solid lightblue;
            margin-top: 20px;
            font-size: 16px;
        }
        
        .main .input .but {
            position: absolute;
            bottom: 20px;
            right: 20px;
        }
        
        .main .input .as {
            font-size: 15px;
            margin-left: 12px;
            width: 120px;
            text-align: center;
            padding: 8px 0px;
            border: 1px solid lightblue;
            border-radius: 3px;
            display: inline-block;
            position: relative;
        }
        
        .main .input .baocun {
            /*    background-color: rgba(75,111,222,.54);*/
            background-color: #4b6fde;
            border-color: white;
        }
        
        .main .input .bocun {
            background-color: #4b6fde;
            border-color: white;
            display: none;
        }
        
        
        .hidd .as a {
            position: absolute;
            right: 10px;
            height: 100%;
            top: 0;
            display: none;
            padding-top: 13px;
        }
        
        .hidd .as a.active {
            display: block;
        }
        
        .hidd .as a p {
            background: black;
            width: 4px;
            height: 4px;
            border-radius: 50%;
            float: left;
            margin-right: 2px;
        }
        
        .bianji {
            width: 100px;
            border-radius: 5px;
            background: #f7e6e6;
            position: absolute;
            top: 102px;
            display: none;
            right: -50px;
            overflow: hidden;
        }
        
        .bianji.active {
            display: block;
        }
        
        .bianji p {
            text-align: center;
            padding: 3px 0;
            font-size: 15px;
        }
        
        .bianji p:hover {
            background: #f2dddd;
        }
    </style>
</head>

<body>
    <div class="boox">
        <h3>待办事项</h3> 
        <li class="add">+ &nbsp;添加事项</li>
        <ul class="list">
             
        </ul>
    </div>
    <div class="main">
        <div class="warp">
            <div class="input">
                <h4>添加<span class="ther"></span></h4>
                <input type="text" placeholder="名称"> 
                <div class="off"><i class="fa fa-times"></i></div>
                <div class="but">
                    <div class="as guanbi">关闭</div>
                    <div class="as baocun">保存</div>
                </div>
            </div>
        </div>
    </div>
    <script>
        var add = document.querySelector(".add")
        var list = document.querySelector(".list")
        var main=document.querySelector(".main")
        add.addEventListener('click', function () {
            main.style.display="block"
        }) 
        var baocun=document.querySelector(".baocun")
        baocun.addEventListener('click',function(){
            var va = document.querySelector(".input input")
            var li = document.createElement('li')
            var span = document.createElement('span')
            var div = document.createElement('div')
            var spantext = document.createTextNode(va.value)
            span.appendChild(spantext)
            var button = document.createElement('button')
            var buttontext = document.createTextNode('删除')
            button.appendChild(buttontext)
            button.addEventListener('click', function () {
                console.log(this.parentNode.parentNode)
                list.removeChild(this.parentNode.parentNode)
            })
            var button1 = document.createElement('button')
            var buttontext1 = document.createTextNode('编辑')
            button1.appendChild(buttontext1)
            button1.addEventListener('click', function () {
                console.log(this.parentNode.parentNode.firstChild.textContent)
                var text=this.parentNode.parentNode.firstChild.textContent
                main.style.display="block"
                document.querySelector(".input input").value=text
                list.removeChild(this.parentNode.parentNode)
            })
            div.appendChild(button)
            div.appendChild(button1)
            li.appendChild(span)
            li.appendChild(div)
            list.appendChild(li)
            console.log(li)
            console.log(span)
            console.log(button)
            va.value = ""
            main.style.display="none"
        })
        var guanbi=document.querySelector(".guanbi")
        guanbi.addEventListener('click',function(){
            console.log(1)
            main.style.display="none"
            var va = document.querySelector(".input input")
            va.value = ""
        }) 
    </script>
</body>

</html>